local nongshi = fk.CreateSkill {
  name = "lingling__nongshi",
}

Fk:loadTranslationTable {
  ["lingling__nongshi"] = "农时",
  [":lingling__nongshi"] = "轮次开始时，你可以选择两种花色，本轮你不能使用这些花色的牌，且每当你使用一张牌时，你摸一张牌。",

  ["@lingling__nongshi-round"] = "农时",
  ["#lingling__nongshi-choice"] = "农时：选择你本轮不能使用的花色，或点取消不发动",
}

nongshi:addEffect(fk.RoundStart, {
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(nongshi.name)
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local suits = { "log_spade", "log_heart", "log_club", "log_diamond" }
    local choices = room:askToChoices(player, {
      choices = suits,
      min_num = 2,
      max_num = 2,
      skill_name = nongshi.name,
      prompt = "#lingling__nongshi-choice",
      cancelable = true,
    })
    if #choices > 0 then
      event:setCostData(self, { choice = choices })
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    player.room:setPlayerMark(player, "@lingling__nongshi-round", event:getCostData(self).choice)
  end,
})

nongshi:addEffect(fk.CardUseFinished, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(nongshi.name) and player:getMark("@lingling__nongshi-round") ~= 0
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    player:drawCards(1, nongshi.name)
  end,
})

nongshi:addEffect("prohibit", {
  prohibit_use = function(self, player, card)
    return player:getMark("@lingling__nongshi-round") ~= 0 and card and
        table.contains(player:getMark("@lingling__nongshi-round"), card:getSuitString(true))
  end,
})

return nongshi
